package com.bawei.bydayzg_two.Utils

import android.content.Context
import android.view.RoundedCorner
import android.widget.ImageView
import com.bawei.bydayzg_two.R
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

class GildUtils {
    companion object{

        fun loadImg(context: Context,url:String,iv:ImageView){
            Glide.with(  context)
                .load(url)
                .placeholder(R.mipmap.ic_launcher)
                .error(R.mipmap.ic_launcher)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .skipMemoryCache(false)
                .centerCrop()
                .into( iv)
        }

        fun loadYuan(context: Context,url:String,iv:ImageView){
            Glide.with(  context)
                .load(url)
                .placeholder(R.mipmap.ic_launcher)
                .error(R.mipmap.ic_launcher)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                //关闭磁盘缓存NONE 合适的缓存策略AUTOMATIC
                .skipMemoryCache(false)
                .circleCrop()
                .into( iv)
        }

        //
        fun loadYJ(context: Context,url:String,iv:ImageView,ds:Int){
            Glide.with(  context)
                .load(url)
                .placeholder(R.mipmap.ic_launcher)
                .error(R.mipmap.ic_launcher)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .skipMemoryCache(false)
                .transform(RoundedCorners(ds))
                .into( iv)
        }
    }
}